import Vue from "vue";
import Router from "vue-router";
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading
/* layout */
import Layout from "../views/layout/Layout";

const _import = require("./_import_" + process.env.NODE_ENV);
Vue.use(Router);
export const constantRouterMap = [
  { path: "/login", component: _import("login/index"), hidden: true },
  { path: "/404", component: _import("404"), hidden: true },
  {
    path: "/",
    component: Layout,
    redirect: "/dashboard",
    name: "首页",
    hidden: true,
    children: [
      {
        path: "dashboard",
        component: _import("dashboard/index")
      }
    ]
  }
];
export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});
export const asyncRouterMap = [
  // {
  //   path: '/system',
  //   component: Layout,
  //   redirect: '/system/article',
  //   name: '功能模块',
  //   meta: {title: '功能模块', icon: 'tree'},
  //   children: [
  //     {
  //       path: 'article',
  //       name: '文章',
  //       component: _import('article/article'),
  //       meta: {title: '文章', icon: 'example'},
  //       menu: 'article'
  //     },
  //   ]
  // },
  {
    path: "/user",
    component: Layout,
    redirect: "/user/",
    name: "user",
    meta: { title: "用户权限", icon: "table" },
    children: [
      {
        path: "",
        name: "用户列表",
        component: _import("user/user"),
        meta: { title: "用户列表", icon: "user" },
        menu: "user"
      },
      {
        path: "role",
        name: "权限管理",
        component: _import("user/role"),
        meta: { title: "权限管理", icon: "password" },
        menu: "role"
      }
    ]
  },
  {
    path: "/task",
    component: Layout,
    redirect: "/task/",
    name: "task",
    meta: { title: "定时任务", icon: "table" },
    children: [
      {
        path: "",
        name: "任务列表",
        component: _import("task/list"),
        meta: { title: "任务列表", icon: "task" },
        menu: "task"
      }
    ]
  },
  {
    path: "/sort",
    component: Layout,
    redirect: "/sort/",
    name: "sort",
    meta: { title: "排名", icon: "table" },
    children: [
      {
        path: "",
        name: "排名",
        component: _import("sort/index"),
        meta: { title: "排名列表", icon: "srot" },
        menu: "sort"
      }
    ]
  },
  { path: "*", redirect: "/404", hidden: true }
];
